#ifndef _AMERICO_INTERCECTION_H_
#define _AMERICO_INTERCECTION_H_

#include "VectorDef.h"

namespace Intersection
{
    struct Sphere
    {
        Vector3f myCenterPosition;
        float myRadius;
        float myRadiusSquared;
    };

    struct LineSegment3D
    {
        Vector3f myStartPos;
        Vector3f myEndPos;
    };


    struct LineSegment2D
    {
        Vector2f myStartPos;
        Vector2f myEndPos;
    };


    struct Plane
    {
        Vector3f myPoint;
        Vector3f myNormal;
    };

    struct AABB
    {
        Vector3f myMinPos;
        Vector3f myMaxPos;
        Vector3f myCenterPos;
        Vector3f myExtents;
    };

    struct OBB
    {
        Vector3f myPoints[8];
    };

    struct Triangle
    {
        Vector3f myPoints[3];
    };

// Helper functions
    Vector3f ClosestPointAABB(const Vector3f &aPoint, const AABB &anAABB);

// lab 1
	bool PointInsideSphere(const Sphere& aSphere,const Vector3f& aTestPoint);		// DONE
	bool PointInsideAABB(const AABB& anAABB,const Vector3f& aTestPoint);			// DONE
	bool PointInsideOBB(const OBB& anOBB,const Vector3f& aTestPoint);				// DONE

    bool LineVsLine(const LineSegment2D& aFirstLine,const LineSegment2D& aSecondLine,Vector3f& anIntersectionPoint); // DONE
	bool LineVsLineRobStyle(const LineSegment2D& aFirstLine,const LineSegment2D& aSecondLine,Vector3f& anIntersectionPoint);

    bool LineVsSphere(const LineSegment3D& aLine,const Sphere& aSphere,Vector3f& anIntersectionPoint);	// DONE
    bool LineVsAABB(const LineSegment3D& aLine,const AABB& anAABB,Vector3f& anIntersectionPoint);		// DONE

    bool SphereVsSphere(const Sphere& aFirstSphere,const Sphere& aSecondSphere);	// DONE
    bool SphereVsAABB(const Sphere& aFirstSphere,const AABB& anAABB);				// DONE
    bool AABBVsAABB(const AABB& aFirstAABB,const AABB& aSecondAABB);				// DONE

// Lab 2

    bool LineVsOBB(LineSegment3D& aLine,OBB& anOBB,Vector3f& anIntersectionPoint);

    bool OBBVsPlane(OBB& anOBB,Plane& aPlane);										// DONE
    bool AABBVsPlane(AABB& anAABB,Plane& aPlane);									// DONE
    bool SphereVsPlane(Sphere& anSphere,Plane& aPlane);								// DONE

	bool LineVsPlane(const LineSegment3D& aLine,const Plane& aPlane, Vector3f& anIntersectionPoint);	// DONE

    bool LineVsTriangle(const LineSegment3D& aLine, const Triangle& aTriangle, Vector3f& anIntersectionPoint);		// DONE



    bool OBBVsAABB(OBB& anOBB,AABB& anAABB);
    bool OBBVsOBB(OBB& aFirstOBB,OBB& aSecondOBB);
};

#endif